package com.hjq.mallsearch.controller;

import com.hjq.common.entity.es.SkuEsModel;
import com.hjq.common.exception.ExceptionEnum;
import com.hjq.common.utils.R;
import com.hjq.mallsearch.service.ProductUpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

/**
 * @auther HJQ
 */
@RestController
@RequestMapping("/mallsearch/es")
public class EsController {
    @Autowired
    private ProductUpService productUpService;
    @PostMapping("/product")
    public R upSkuProducts(@RequestBody List<SkuEsModel> skuEsModels){
        try {
            boolean b = productUpService.productStatusUp(skuEsModels);
            return  b?R.ok():R.error();
        } catch (IOException e) {
            e.printStackTrace();
            return  R.error(ExceptionEnum.UPDPRODUCT_EXCEPTION.getNumber(),ExceptionEnum.UPDPRODUCT_EXCEPTION.getMsg());
        }

    }
}
